﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Signalr;

namespace SignalRChat.Controllers
{
    public class EchartController : Controller
    {

        private IHubContext<ChatHub> _hubContext;

        public EchartController(IHubContext<ChatHub> hubContext)
        {
            this._hubContext = hubContext;
        }

        public IActionResult Index()
        {
            return View();
        }


        public async Task<IActionResult> sendmsg()
        {

            var message = Request.Form["message"];
            await _hubContext.Clients.All.SendAsync("ReceiveMessage", new { msg = message });
            return Json(new { code = "success", msg = "发送成功" });


        }
    }
}